#include <bits/stdc++.h>
#define int long long
using namespace std;

class Matrix {
public:
    int n, m, a[101][101];
    Matrix(int N, int M)
    {
        n = N, m = M;
        memset(a, 0, sizeof a);
    }
    Matrix operator*(Matrix& b)
    {
        Matrix c(n, b.m);
        for (int i = 1; i <= n; i++)
            for (int j = 1; j <= b.m; j++)
                for (int k = 1; k <= m; k++)
                    c.a[i][j] += a[i][k] * b.a[k][j], c.a[i][j] %= 1000000007;
        return c;
    }
};

Matrix quick_pow(Matrix a, int k)
{
    Matrix ans(a.n, a.n);
    for (int i = 1; i <= a.n; i++)
        ans.a[i][i] = 1;
    while (k) {
        if (k & 1)
            ans = ans * a;
        a = a * a;
        k >>= 1;
    }
    return ans;
}

signed main()
{
    Matrix a(3, 1);
    a.a[1][1] = 1, a.a[2][1] = 1, a.a[3][1] = 1;
    Matrix b(3, 3);
    b.a[1][1] = 1, b.a[1][3] = 1, b.a[2][1] = 1, b.a[3][2] = 1;
    int t;
    cin >> t;
    while (t--) {
        int x;
        cin >> x;
        if (x <= 3) {
            cout << 1 << endl;
            continue;
        }
        Matrix ans = quick_pow(b, x - 3) * a;
        cout << ans.a[1][1] << endl;
    }
    return 0;
}